#!/bin/bash
PROJECT="doctor"
COM="dianyitai"
VERSION="0.0.1-SNAPSHOT"
BAK_DIR=/home/jenkins/bak/$PROJECT/`date +%Y%m%d`
WORKSPACE=/home/jenkins/workspace

mkdir -p "${BAK_DIR}"
cp ${WORKSPACE}/${PROJECT}/target/"${PROJECT}-${VERSION}".jar "${BAK_DIR}"/"${PROJECT}"_`date +%Y%m%d%H%M%S`.jar
cp ${WORKSPACE}/${PROJECT}/target/"${PROJECT}-${VERSION}".jar ${WORKSPACE}/${PROJECT}/src/main/docker


docker rm -f ${PROJECT}
docker rmi ${COM}/${PROJECT}
sleep 3s
cd ${WORKSPACE}/${PROJECT}/src/main/docker
docker build -t ${COM}/${PROJECT} .
sleep 10s
docker run --name ${PROJECT} -p 1112:1112 ${COM}/${PROJECT} -d